package com.geline.easytrans.dict;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 枚举转字典工具类
 * @author: mengxin
 * @date: 2023/4/26 15:08
 */
public class IDictUtil {

    public static List<DictOptions> toList(Class<? extends IDict> clazz){
        IDict[] constants = clazz.getEnumConstants();
        return Stream.of(constants).map(row ->{
            DictOptions options = new DictOptions();
            options.setDictLabel(row.getLabel());
            options.setDictValue(row.getValue());
            options.setIsDefault(row.getDefault());
            return options;
        }).collect(Collectors.toList());
    }
}
